/**
 * 
 */
package net.homelinux.ajay.net.ondisk.view.client;



import net.homelinux.ajay.net.ondisk.model.client.AppObject;
import net.homelinux.ajay.net.ondisk.model.client.Collection;
import net.homelinux.ajay.net.ondisk.view.menu.client.CollectionMenuBuilder;

import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author ajay
 *
 */
public class CollectionTreeItem extends FolderTreeItem {

  private static AppTreeItem dragTarget = CollectionCommandsTreeItem.getDragTarget();
  

  private final static String imageUrl = "images/cd.png";


  private Collection collection;

  /**
   * 
   */
  public CollectionTreeItem() {
  }
    
  /**
   * @param html
   */
  public CollectionTreeItem(String html, Collection collection) {
    super(html, collection, getImage());
    this.collection = collection;
  }
  private static Image getImage() {
    Image img = new Image(imageUrl);
    img.setSize("24", "24");
    return img;
  }

//  /**
//   * @param widget
//   */
//  public CollectionTreeItem(Widget widget) {
//    super(widget);
//  }
  
  public static CollectionTreeItem makeCollectionTreeItem(String name,CollectionsTreeItem parent) {
    CollectionTreeItem itm2;
    
    itm2 = new CollectionTreeItem(name,parent.getMeta().makeCollection(name));
//    String itemwidth = "10em";
//    itm2.setWidth(itemwidth);
    if(parent!=null){
      parent.addItem(itm2);
    }
    return itm2;
  }


//  public void onDeselect() {
//    super.onDeselect();
//    //removeItem(getDragTarget());
//  }
//
//  public void onSelect() {
//    //addItem(getDragTarget());
//    
//    super.onSelect();
//    
//    setState(true);
//  }

//TODO: implement onMetaChange()
//  public void onMetaChange(AppObject meta) {
//    
//  }

  protected CommandsMenu getCommandsMenu() {
    CommandsMenu contextMenu = CollectionMenuBuilder.getInstance(AppTree.getTree()).makeContextMenu();
    return contextMenu;
  }
  

}
